using System;
using System.IO;
using System.Xml;
using System.ComponentModel;
using System.Windows.Forms;

namespace UILayer.DPAppUIForms
{
	public class ThemeManager
	{
		public static string GetDefaultThemePath()
		{
			string filename = System.Windows.Forms.Application.StartupPath + @"\Themes.config";
			if( ! File.Exists( filename ) )
			{
				System.Windows.Forms.MessageBox.Show(null,
					"Unable to read the theme filename : "+filename+" , the icons will be unavailable",
					"Theme support not available");
				return "";
			}
			XmlDocument document = new XmlDocument();
			document.Load( filename );
			XmlElement themes = document.DocumentElement;
			string defaultTheme = themes.GetAttribute("current");
			/*
			XmlElement elem = themes.SelectSingleNode( 
				String.Format( "./Theme[@name='{0}']" , defaultTheme )
			) as XmlElement;
			*/
			foreach ( XmlNode node in themes.ChildNodes)
			{
				//MessageBox.Show("string",node.Attributes["name"].Name);
				if(node.Attributes["name"].Value==defaultTheme)
				{
					//MessageBox.Show(Application.StartupPath+@"\"+node.Attributes["path"].Value,":^)");
					return  Application.StartupPath+@"\"+node.Attributes["path"].Value;
				}
			}
			return "";
			//if( elem == null )
			//	return "";
			//return elem.GetAttribute("path");
		}
	}
}
